Add owner types for widget actions
authorMatthias Clasen <mclasen@redhat.com>
Sat, 22 Jun 2019 13:35:57 +0000 (09:35 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 22 Jun 2019 13:38:30 +0000 (09:38 -0400)
This lets us filter out actions from parent classes
when introspecting.

gtk/gtkactionmuxerprivate.h
gtk/gtkwidget.c
gtk/gtkwidget.h

index 5a1218d84ac11d887b99a422a30afcde31fcb291..b1b8cef9cc5ddc90b60574665286551ec05179eb 100644 (file)
@@ -34,6 +34,7 @@ G_BEGIN_DECLS
 typedef struct {
   char *name;
 
+  GType owner;
   GVariantType *parameter_type;
   GVariantType *state_type;
 
index c96909a5e08d5ace352a8518816fc6dc40d3702a..de0ed764dcfc970f6f19047671b0703c6c03617d 100644 (file)
@@ -13503,6 +13503,7 @@ gtk_widget_class_install_stateful_action (GtkWidgetClass              *widget_cl
     }
 
   action = g_new0 (GtkWidgetAction, 1);
+  action->owner = G_TYPE_FROM_CLASS (widget_class);
   action->name = g_strdup (action_name);
   action->activate = activate;
   action->parameter_type = parameter_type ? g_variant_type_new (parameter_type) : NULL;
@@ -13568,6 +13569,7 @@ gtk_widget_action_state_changed (GtkWidget  *widget,
  * gtk_widget_class_query_action:
  * @widget_class: a #GtkWidgetClass
  * @index_: position of the action to query
+ * @owner: the type where the action was defined
  * @action_name: return location for the action name
  * @parameter_type: return location for the parameter type
  * @state_type: return location for the state type
@@ -13576,12 +13578,17 @@ gtk_widget_action_state_changed (GtkWidget  *widget,
  * a widget class using gtk_widget_class_install_action()
  * during class initialization.
  *
+ * Note that this function will also return actions defined
+ * by parent classes. You can identify those by looking
+ * at @owner.
+ *
  * Returns: %TRUE if the action was found,
  *     %FALSE if @index_ is out of range
  */
 gboolean
 gtk_widget_class_query_action (GtkWidgetClass      *widget_class,
                                guint                index_,
+                               GType               *owner,
                                const char         **action_name,
                                const GVariantType **parameter_type,
                                const GVariantType **state_type)
@@ -13592,6 +13599,7 @@ gtk_widget_class_query_action (GtkWidgetClass      *widget_class,
     {
       GtkWidgetAction *action = g_ptr_array_index (priv->actions, index_);
 
+      *owner = action->owner;
       *action_name = action->name;
       *parameter_type = action->parameter_type;
       *state_type = action->state_type;
index 31161141edd7da050915433b12c4d619cba63d83..4893910fb9e2152331ff6cd3ab3d2bf80e0da7cc 100644 (file)
@@ -1087,6 +1087,7 @@ void                    gtk_widget_class_install_stateful_action (GtkWidgetClass
 GDK_AVAILABLE_IN_ALL
 gboolean               gtk_widget_class_query_action  (GtkWidgetClass      *widget_class,
                                                        guint                index_,
+                                                       GType               *owner,
                                                        const char         **action_name,
                                                        const GVariantType **parameter_type,
                                                        const GVariantType **state_type);